package top.bigdata.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.bigdata.model.dto.Response;
import top.bigdata.model.dto.author.HotAuthor;
import top.bigdata.model.dto.author.MonthlyAuthor;
import top.bigdata.service.api.AuthorService;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/author")
@Tag(name = "作者接口")
public class AuthorController {
    private final AuthorService authorService;

    @GetMapping("/getHotAuthor")
    @Operation(
            summary = "获取最热up主",
            parameters = {@Parameter(name = "tid", description = "分区id，为0时获取全站")}
    )
    public Response<List<HotAuthor>> getHotAuthor(@RequestParam(name = "tid", defaultValue = "0") int tid) {
        return Response.success(authorService.getHotAuthors(tid));
    }

    @GetMapping("/getHotAuthorByTag")
    @Operation(
            summary = "获取与标签相关的最热up主",
            parameters = {@Parameter(name = "tag", description = "标签名")}
    )
    public Response<List<HotAuthor>> getHotAuthorByTag(@RequestParam(name = "tag") String tag) {
        return Response.success(authorService.getHotAuthorsByTag(tag));
    }

    @GetMapping("/getDataMonthly")
    @Operation(
            summary = "获取作者月度数据",
            parameters = {@Parameter(name = "mid", description = "作者mid")}
    )
    public Response<List<MonthlyAuthor>> getDataMonthly(@RequestParam(name = "mid") long mid) {
        return Response.success(authorService.getDataMonthly(mid));
    }
}
